package com.regentsoft.cloudback.operateAdmin.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.regentsoft.cloudback.enterpriseAdmin.entity.CompanyAdminModel;
import com.regentsoft.cloudback.util.RedisClient;

/**
 * 运营管理后台token管理
 * @author czd
 *
 * @date 2017年11月29日
 *
 * @version 1.0
 */
@Component
public class SysAdminTokenManager {
	 private final RedisClient client;

	    private final String REDIS_KEY = "SYS_TOKEN_";

	    private final int seconds = 6000;

	    @Autowired
	    public SysAdminTokenManager(RedisClient client) {
	        this.client = client;
	    }

	    public boolean exists(String key){
	        return client.exists(formatKey(key));
	    }

	    public String set(String key,CompanyAdminModel model){
	        return client.set(formatKey(key),seconds,model);
	    }

	   

	    private String formatKey(String key){
	        return REDIS_KEY.concat(key);
	    }
}
